import Vuex from 'vuex'
import Vue from 'vue'

Vue.use(Vuex)

let state = {
    loading: false,
    pageTitile:sessionStorage.pageTitile || '',
    isBack:sessionStorage.isBack || '1' ,  //1 为展示 0为不展示 

}

let actions = {
    setLoading({ commit }, info) {
        commit('SET_LOADING', info)
    },
  
    setPageTitle({ commit }, info) {
        commit('SET_PAGE_TITLE', info)
    },

    setIsBack({ commit }, info){
        commit('SET_IS_BACK', info)
    }

}

let mutations = {
    SET_LOADING(state, info) {
        state.loading = info
    },

    SET_PAGE_TITLE(state, info){
        document.title = info
        sessionStorage.pageTitile = info
        state.pageTitile = info
    },

    SET_IS_BACK(state, info){
        sessionStorage.isBack = info
        state.isBack = info
    }

}

let getters = {
    loading: state => state.loading,
    pageTitile: state => state.pageTitile,
    isBack: state => state.isBack
}


export default  new Vuex.Store({
    state,
    actions,
    mutations,
    getters,
   
})

